package com.aramco.fion.service
{
	
	
	import com.aramco.fion.model.AppModel;
	import com.aramco.fion.model.FlexConstants;
	
	import mx.messaging.messages.HTTPRequestMessage;
	import mx.rpc.AsyncToken;
	import mx.rpc.http.HTTPService;
	
	import org.swizframework.utils.services.MockDelegateHelper;
	import org.swizframework.utils.services.ServiceHelper;
	
	
	public class AppDelegate implements IAppDelegate
	{

		[Inject]
		public var serviceRequestUtil: ServiceHelper;
		
		[Inject]
		public var model:AppModel;
		
		
		protected var util:MockDelegateHelper;
		
		public function AppDelegate()
		{
			util = new MockDelegateHelper(true);
		}
		
		
		var myService:HTTPService;
		public function loadApp():AsyncToken
		{
			myService = new HTTPService();
			//myService.url = _commonModel.completeURL + FlexConstants.BSP_04_URL + '?query=' + 'Report%2F'+ targetState.queryName + FlexConstants.BSP_04_URL_FLAGS;
			myService.url = "app.xml";
			myService.method = "GET";
			myService.resultFormat = "e4x";
			myService.showBusyCursor = true;
			myService.headers["Pragma"] = "no-cache"; 
			myService.headers["Cache-Control"] = "no-cache";
			return myService.send();		
		}
		
		public function sendEmail(paramters:Object):AsyncToken
		{
			myService = new HTTPService();
			myService.url = model.completeURL + FlexConstants.BSP_07_URL  ;
			//myService.url = "email.xml";
			myService.method = "GET";
		//	myService.resultFormat = "e4x";
		//	myService.showBusyCursor = true;
			myService.headers = paramters;
		myService.headers["Pragma"] = "no-cache"; 
		myService.headers["Cache-Control"] = "no-cache";
			return myService.send(paramters);	
		}
	}
}